var plusready = [],
	ishtml5plus = false;
if (/html5plus/i.test(navigator.userAgent) || window.plus) {
	ishtml5plus = true;
	window.plus || document.addEventListener("plusready", function() {
		var callback;
		while (callback = plusready.shift()) {
			callback();
		}
	}, false);
}
export default {
	//获取当前网络类型
	networkinfo: function() {
		switch (plus.networkinfo.getCurrentType()) {
			case plus.networkinfo.CONNECTION_ETHERNET:
			case plus.networkinfo.CONNECTION_WIFI:
				return 'free';
			case plus.networkinfo.CONNECTION_CELL2G:
			case plus.networkinfo.CONNECTION_CELL3G:
			case plus.networkinfo.CONNECTION_CELL4G:
				return 'charge';
			case plus.networkinfo.CONNECTION_UNKNOW:
				return 'unknow';
			case plus.networkinfo.CONNECTION_NONE:
			default:
				return false;
		}
	},
	//H5+准备就绪
	plusready: function(callback, other) {
		if (ishtml5plus === false) {
			other();
		} else if (window.plus) {
			callback();
		} else {
			plusready.push(callback);
		}
	}
};
